<template>
    <div style="background:#fff">
        <div class="big">
            <div class="com">
                <el-button @click="addFn">+</el-button>
                <el-slider v-model="value" vertical height="200px">
                </el-slider>
                <el-button @click="cutFn">-</el-button>
            </div>

            <div class="wapper">
                <div class=" samll">
                    <table class="table" border="1" cellspacing="0" >
                        <tr v-for="item in row" :key="item">{{item}}
                            <td v-for="jtem in col " :key="jtem" :style="styleNum">{{jtem}}</td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            row: [1, 2, 3, 4],
            col: [1, 2, 3, 4, 5, 6],
            value: 50,
            positionX: 0,
            positionY: 0,
        }
    },
    methods: {

        addFn() {
            if (this.value >= 0 && this.value <= 200) {
              
                this.value += this.value % 10
                console.log(this.value);
            }
        },
        cutFn() {
            if (this.value >= 0 && this.value <= 100) {
                this.value -= this.value % 10
                console.log(this.value);
            }
        },
        // return `width:100${+this.value}px;height:50${+this.value}px`
        move(e) {
            let odiv = e.target;        //获取目标元素

            //算出鼠标相对元素的位置
            let disX = e.clientX - odiv.offsetLeft;
            let disY = e.clientY - odiv.offsetTop;
            document.onmousemove = (e) => {       //鼠标按下并移动的事件
                //用鼠标的位置减去鼠标相对元素的位置，得到元素的位置
                let left = e.clientX - disX;
                let top = e.clientY - disY;

                //绑定元素位置到positionX和positionY上面
                this.positionX = top;
                this.positionY = left;

                //移动当前元素
                odiv.style.left = left + 'px';
                odiv.style.top = top + 'px';
            };
            document.onmouseup = (e) => {
                console.log(e);
                document.onmousemove = null;
                document.onmouseup = null;
            };
        }

    }
    ,
    computed: {
        styleNum() {
            return `width:${100 + this.value}px;height:${50 + this.value}px`
        }
    }
}
</script>

<style lang='scss' scoped>
td {
  width: 100px;
  height: 50px;
}
.wapper {
  width: 800px;
  height: 400px;
  overflow: hidden;
}
.samll {
  //   width: 400px;
  height: 200px;
  border: 1px solid #000;
  //   overflow: hidden;
  overflow-x: auto;
  //   overflow-y: auto;
}
// .samll {
//   //   text-align: center;
// }
#wapper {
  position: relative;
}
// .table {
//   /* flex: 1; */
// }
</style>